/**
 * 
 */
package com.swim.swimteach.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.swim.swimteach.entity.SwimTeachVideo;
import com.swim.swimteach.service.SwimTeachVideoService;

/**
 * 游泳视频教学表Controller
 * @author 刘军武
 * @version 2021-05-31
 */
@Controller
@RequestMapping(value = "${adminPath}/swimteach/swimTeachVideo")
public class SwimTeachVideoController extends BaseController {

	@Autowired
	private SwimTeachVideoService swimTeachVideoService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public SwimTeachVideo get(String id, boolean isNewRecord) {
		return swimTeachVideoService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("swimteach:swimTeachVideo:view")
	@RequestMapping(value = {"list", ""})
	public String list(SwimTeachVideo swimTeachVideo, Model model) {
		model.addAttribute("swimTeachVideo", swimTeachVideo);
		return "swim/swimteach/swimTeachVideoList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<SwimTeachVideo> listData(SwimTeachVideo swimTeachVideo, HttpServletRequest request, HttpServletResponse response) {
		Page<SwimTeachVideo> page = swimTeachVideoService.findPage(new Page<SwimTeachVideo>(request, response), swimTeachVideo); 
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("swimteach:swimTeachVideo:view")
	@RequestMapping(value = "form")
	public String form(SwimTeachVideo swimTeachVideo, Model model) {
		model.addAttribute("swimTeachVideo", swimTeachVideo);
		return "swim/swimteach/swimTeachVideoForm";
	}

	/**
	 * 保存游泳视频教学表
	 */
	@RequiresPermissions("swimteach:swimTeachVideo:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated SwimTeachVideo swimTeachVideo) {
		swimTeachVideoService.save(swimTeachVideo);
		return renderResult(Global.TRUE, text("保存游泳视频教学表成功！"));
	}
	
	/**
	 * 删除游泳视频教学表
	 */
	@RequiresPermissions("swimteach:swimTeachVideo:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(SwimTeachVideo swimTeachVideo) {
		swimTeachVideoService.delete(swimTeachVideo);
		return renderResult(Global.TRUE, text("删除游泳视频教学表成功！"));
	}
	
	/**
	 * 获取详情数据
	 */
	@RequestMapping(value = "detailsData")
	@ResponseBody
	public String detailsData(String swimTeachVideoId) {
		return renderResult(Global.TRUE, text("获取详情数据成功！"), swimTeachVideoService.get(swimTeachVideoId));
	}
}